package com.xiaoai.httpClientTestService.controller;

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.DispatcherServlet;

import com.xiaoai.httpClientTestService.entity.Person;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {

    @RequestMapping(value = "/test/getpGet",method = RequestMethod.GET)
    @ResponseBody
    public String getPersonGet1(){
        return "hello!!!--get";
    }

    @RequestMapping(value = "/test/getpGetParam",method = RequestMethod.GET)
    @ResponseBody
    public Person getPersonGet2(String name,String sex){
        Person p = new Person(name,sex);
        System.out.println(p);
        return p;
    }

    @RequestMapping(value = "/test/getpPost",method = RequestMethod.POST)
    @ResponseBody
    public String getPersonPost1(){
        return "hello!!!--post";
    }

    @RequestMapping(value = "/test/getpPostParam",method = RequestMethod.POST)
    @ResponseBody
    public Person getPersonPost2(Person person){
        System.out.println(person);
        return person;
    }

    @RequestMapping(value = "/test/getpPostParamJson",method = RequestMethod.POST)
    @ResponseBody
    public Person getPersonPost3(@RequestBody Person person){
        System.out.println(person);
        return person;
    }
}
